#!/bin/sh

export DEBFULLNAME="PowerDNS.COM BV AutoBuilder"
export DEBEMAIL="noreply@powerdns.com"

if [ "$0" != "./build-scripts/build-auth-debian" ]; then
  echo "Please run me from the root checkout dir"
  exit 1
fi

if [ -z "$VERSION" ]; then
  echo 'Please set $VERSION' >&2
  exit 1
fi

if [ -z "$RELEASE" ];then
  echo 'Please set $RELEASE' >&2
  exit 1
fi

DISTDIR=${DISTDIR:=.}

set -e
set -x

rm -rf $DISTDIR/debian/
cp -r build-scripts/debian-authoritative $DISTDIR/debian

cd $DISTDIR

cat > debian/changelog << EOF
pdns (${VERSION}-${RELEASE}) unstable; urgency=medium

  * Automatic build

 -- PowerDNS.COM AutoBuilder <noreply@powerdns.com>  $(date -R)

EOF
DH_OPTIONS=--parallel fakeroot debian/rules binary
